<%-- 
    Document   : result
    Created on : Dec 4, 2011, 8:07:33 PM
    Author     : Vu Nhat
--%>

<%@page import="m12cqis01.nhathv.util.Constants" %>
<%@page import="m12cqis01.nhathv.vo.ResultVO"%>
<%@page import="m12cqis01.nhathv.vo.QueryVO"%>
<%@page import="m12cqis01.nhathv.util.BoDauTiengViet" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="header.jsp"%>

<center >
    <%
        String query = (String) request.getAttribute("query");
    %>

    <form name="search" action="SearchServlet" method="get">
        <p>
            <input type="hidden" name="action" value="search">
            <input name="query" size="44" style="width: 400px" value="<%=query%>"/>&nbsp;<input type="submit" value="Truy vấn"/>            
        </p>
    </form>
</center>

<%
    ResultVO resultVO = (ResultVO) request.getAttribute("resultVO");
    if ((resultVO == null) || (resultVO != null && resultVO.getResult().equalsIgnoreCase(""))) {
%>
<h1> Không có kết quả!</h1>
<%
} else {
        QueryVO queryVO = resultVO.getQueryVO();
%>
<h2> <%= BoDauTiengViet.toVietNamNatural(queryVO.getRequirement())%> của 
    <%= BoDauTiengViet.toVietNamNatural(queryVO.getProductName())%> 
    <%= queryVO.getProducer()%> 
    <%= queryVO.getProductCode().toUpperCase() %> là: 
    <br>
    <%
        if (queryVO.getProductName().equalsIgnoreCase(Constants.TH_THONGSO)){

        String[] res = resultVO.getResult().split("-");
        if (res.length > 1){
            for (int i = 0; i < res.length; i++){
            
            
    %> 
    <%= res[i] %> <br>
    <%      }
        } else {
    %>
        <%= resultVO.getResult()%> </h2>
    <%  } 
       } else {
                %>
        <%= resultVO.getResult()%> </h2>
    <%   }
    %>
<h4>Chi tiết : <a href="<%=resultVO.getUrl()%>"> <%=resultVO.getUrl()%></a> </h4>
<h4>Thời gian truy vấn: <%= request.getAttribute("time") %> giây</h4>
<%
    }
%>


<%@include file="footer.jsp"%>
